import { dateFormat } from "./../utils/index";

// 获取当天或者距离近时间的日期
export default function (type: string, distance = 0) {
  const date = new Date().getTime() + distance * 1000 * 60 * 60 * 24;

  // 返回结果
  let result = "";

  if (type === "yyyy-MM-dd") {
    result = dateFormat(date, "yyyy-MM-dd");
  } else if (type === "yyyy-MM-dd hh:mm:ss") {
    result = dateFormat(date, "yyyy-MM-dd hh:mm:ss");
  } else if (type === "hh:mm:ss") {
    result = dateFormat(date, "hh:mm:ss");
  } else {
    result = date.toString();
  }
  return result;
}
